package com.spark.actions.hrm;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;

import com.spark.actions.sys.DefaultAction;
import com.spark.core.Message;
import com.spark.core.SparkContext;
import com.spark.dao.SessionFactory;



public class EmployeeAction extends DefaultAction {
	
	
	
	@SuppressWarnings("unchecked")
	public void createEmployee(SparkContext context) throws Exception {
		Map requestData = getRequestData(context);
		List list = (List)requestData.get(PARAMETER);
		Message message = new Message(true);
		if(list!=null && list.size() > 0){
			Map map = (Map)list.get(0);
			if(isNotEmpty(map.get("EMPLOYEE_NAME"), message,"姓名不能为空!")){
				SqlSession sqlSession = SessionFactory.getSession();
				try {
					setCompanyId(map, context);
					sqlSession.insert("hrm_lbr_employee.insert",map);
				} finally {
					SessionFactory.closeSession(sqlSession);
				}
			}
			message.setResult(list);
			writeMessage(context, message);
		}
	}
}
